//
//  HomeWatherViewController.m
//  ioschishan
//
//  Created by 马田成 on 2017/7/28.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeWatherViewController.h"

#import "MJRefresh.h"
#import "MJRefreshHeader.h"
#import "MJRefreshFooter.h"
#import "HomePicDetailsViewController.h"

#import "HomeCrowdfundingViewController.h"
#import "HomeOneBigPicTableViewCell.h"
#import "RemarksCellHeightModel.h"
#import "HomeNewMorePicCell.h"
#import "HomeOneHangTableViewCell.h"
#import "HomeTwoHangTableViewCell.h"
#import "HomeThreeHangTableViewCell.h"
#import "HomeForwardOneHangCell.h"
#import "ForwardDetailsViewController.h"
#import "HomeNoPicTableViewCell.h"


@interface HomeWatherViewController ()<UITableViewDelegate, UITableViewDataSource,CAAnimationDelegate, HomeOneBigPicCellDelegate, HomeNewMorePicCellDelegate, HomeOneHangCellDelegate, HomeTwoHangCellDelegate,HomeThreeHangCellDelegate, HomeForwardOneHangCell,HomeNoPicCellDelegate>
{
    BOOL _isShow; // 是否展开
    NSString *_cellContentStr; // 备注消息
    
}


@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@property (nonatomic, strong) NSMutableArray *arrMu;//图片数组

@property (nonatomic, strong) NSMutableArray *dataSource;//内容数组
// 存放cell视图展开状态的字典
@property (nonatomic, strong) NSMutableDictionary *cellIsShowAll;
@property (nonatomic, assign) NSInteger page;
@property (nonatomic, strong) NSMutableDictionary *dictOfSection;//官方数据


@end

@implementation HomeWatherViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.cellIsShowAll = [NSMutableDictionary dictionary];
    }
    return self;
}



- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
}

- (void)zj_viewDidLoadForIndex:(NSInteger)index {
    //    NSLog(@"%@",self.view);
    //    NSLog(@"%@", self.zj_scrollViewController);
    _dataSource = [[NSMutableArray alloc] init];
    _page = 1;
    [self creationView];
    [self leftNavHide];
    
    
}
- (void)zj_viewWillAppearForIndex:(NSInteger)index {
    // NSLog(@"viewWillAppear------");
    
    [self creationData];
    __weak typeof(self) weakself = self;
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        
        [weakself creationDataJZ];
    }];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakself creationData];
        
        [self.tableView.mj_header beginRefreshing];
    }];


}


- (void)zj_viewDidAppearForIndex:(NSInteger)index {
    // NSLog(@"viewDidAppear-----");
    
}
- (NSMutableArray *)photoDeleSource{
    if (!_arrMu) {
        _arrMu = [NSMutableArray array];
    }
    return  _arrMu;
}
- (NSMutableArray *)photoDeleSourceaaa{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return  _dataArr;
}
//- (NSMutableArray *)photoDeleSourcea{
//    if (!_dataSource) {
//        _dataSource = [NSMutableArray array];
//    }
//    return  _dataSource;
//}
- (NSMutableDictionary *)bonus{

    if (!_dictOfSection) {
        _dictOfSection = [[NSMutableDictionary alloc] init];
        
    }
    return _dictOfSection;
    
}
- (void)creationView{
    
    [self setTitle:@"天边彩虹"];
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 49);
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
    //    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//去掉cell分割线
    
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
}
- (void)creationData{
    
    //  _dataArr = [NSMutableArray array];
    
    [self.tableView.mj_header endRefreshing];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    
    _page = 1;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //    NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_IndexIndex_water networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            NSDictionary *dict1=[returnData objectForKey:@"data"];
            [self.dataSource removeAllObjects];
            self.dataArr = [dict1 objectForKey:@"circle"];
            _dictOfSection = [dict1 objectForKey:@"bonus"];
            _cellContentStr = [[dict1 objectForKey:@"bonus"] objectForKey:@"content"];
            
            NSLog(@"QQQQQQQQQQQQQQQQQQQQQ%@", self.dataArr);
            
            for (int i = 0; i<self.dataArr.count; i++) {
                
                NSString *str = [self.dataArr[i] objectForKey:@"content"];
                [self.dataSource addObject:str];
            }
            NSLog(@"WWWWWWWWWWWWWWWWWW%@", self.dataSource);
            
            [self.tableView reloadData];

            [hud removeFromSuperview];
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        [hud removeFromSuperview];
    }];
    
}
- (void)creationDataJZ{
    
    _page++;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //  NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_IndexIndex_water networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            NSDictionary *dict1=[returnData objectForKey:@"data"];
            NSMutableArray *arr =[dict1 objectForKey:@"circle"];
            
            if (arr.count == 0) {
                
                [self.tableView.mj_footer endRefreshing];
                
            }else {
                
                [self.dataArr addObjectsFromArray:arr];
                NSLog(@"%@", self.dataArr);
                for (int i = 0; i<arr.count; i++) {
                    
                    NSString *str = [arr[i] objectForKey:@"content"];
                    [self.dataSource addObject:str];
                    
                }
                NSLog(@"JZJZJZJZJZJJZJZJZJZJZJJZJZ%@", self.dataSource);
                
                
            }
            
            [self.tableView reloadData];
            [self.tableView.mj_footer endRefreshing];
            
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            [self.tableView.mj_footer endRefreshing];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        
    }];
    
}

#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}


#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
    
}
//section 不随tableView滑动
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    if (scrollView == self.tableView)
        
    {
        
        CGFloat sectionHeaderHeight = 64; //header高度
        
        if (scrollView.contentOffset.y <= sectionHeaderHeight && scrollView.contentOffset.y >= 0) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
            
        } else if (scrollView.contentOffset.y >= sectionHeaderHeight) {
            
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
            
        }
        
    }
    
    
    
}
#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if (section == 0) {
        return 1;
    }else {
        
        return self.dataArr.count;
        
    }


}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    self.arrMu = [self.dataArr[indexPath.row] objectForKey:@"circle_pic"];
    NSMutableDictionary *dicOfFor = [[NSMutableDictionary alloc] init];
    dicOfFor = [self.dataArr[indexPath.row] objectForKey:@"forward_circle"];
    
    NSString *dictOfForward = [dicOfFor objectForKey:@"id"];
    
    
    if (indexPath.section == 0) {
        
        return [RemarksCellHeightModel cellHeightWith:_cellContentStr andIsShow:_isShow andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8]+ 61 + 24 + 35;
        
        
    }else{
        if (self.arrMu.count == 1) {
            
            // 返回Cell高度
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + 190 + 24 + 35;
            
        }else if (self.arrMu.count > 1 && self.arrMu.count <= 3){
            
            // 返回Cell高度
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + (DEF_SCREEN_WIDTH - 48) / 3 + 28 + 35;
            
            
        }else if (self.arrMu.count > 3 && self.arrMu.count <= 6) {
            // 返回Cell高度
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + (DEF_SCREEN_WIDTH - 48) / 3 * 2 + 33 + 40;
            
            
        }else if (self.arrMu.count > 6 && self.arrMu.count <= 9) {
            
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + (DEF_SCREEN_WIDTH - 48) + 42 + 40;
            
        }else if ([dictOfForward length] != 0 && self.arrMu.count == 0){
            
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + (DEF_SCREEN_WIDTH - 48) / 3 + 24 + 35 + 48;
            
        }else {
            
            return [RemarksCellHeightModel cellHeightWith:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue] andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8] + 61 + 24 + 35;
            
            
        }
        
    }
    
    
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSMutableDictionary *dict1 = self.dataArr[indexPath.row];

    NSMutableDictionary *dicOfFor = [[NSMutableDictionary alloc] init];
    dicOfFor = [self.dataArr[indexPath.row] objectForKey:@"forward_circle"];
    
    NSString *dictOfForward = [dicOfFor objectForKey:@"id"];
    self.arrMu = [self.dataArr[indexPath.row] objectForKey:@"circle_pic"];

    if (indexPath.section == 0) {
        static NSString *cellName = @"HomeNewMorePicCell";
        HomeNewMorePicCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        if (!cell) {
            cell = [[HomeNewMorePicCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
            cell.delegate = self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
         [cell setCellContent:_cellContentStr andIsShow:_isShow  andCellIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.infolable.text = [self.dictOfSection objectForKey:@"name"];
        cell.labelOfTime.text = [self.dictOfSection objectForKey:@"add_time"];
        NSString *urlHeaderPic = manage(AP_HOST, [self.dictOfSection objectForKey:@"header_img"]);
        [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
        
        
        NSString *urlPic = manage(AP_HOST, [self.dictOfSection objectForKey:@"pic"]);
        [cell.picImage sd_setImageWithURL:[NSURL URLWithString:urlPic] placeholderImage:[UIImage imageNamed:@""]];
        
        
        return  cell;
        
        
    }else{
        if (self.arrMu.count ==1) {
            
            static NSString *cellName = @"meTableViewCell";
            HomeOneBigPicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeOneBigPicTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            
            
            if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"1"]) {
                cell.labelTeacher.text = @"普通";
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"2"]){
                cell.labelTeacher.text = @"老师";
                
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"3"]){
                cell.labelTeacher.text = @"大V";
                
            }else {
                
                cell.labelTeacher.text = @"官方";
            }
            
            
            
            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
            
            NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
            
            [cell.picImage sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
            
            cell.picImage.contentMode = UIViewContentModeScaleAspectFill;
            cell.picImage.clipsToBounds = YES;
            cell.picImage.userInteractionEnabled = YES;
            
            
            
            return cell;
        }else if (self.arrMu.count > 1 && self.arrMu.count <= 3){
            
            static NSString *cellName = @"HomeOneHangTableViewCell";
            HomeOneHangTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeOneHangTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"1"]) {
                cell.labelTeacher.text = @"普通";
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"2"]){
                cell.labelTeacher.text = @"老师";
                
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"3"]){
                cell.labelTeacher.text = @"大V";
                
            }else {
                
                cell.labelTeacher.text = @"官方";
            }
            
            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
            
            if (self.arrMu.count == 2) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                cell.picImage3.hidden = YES;
                
            }else {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
            }
            
            return cell;
            
            
            
        }else if (self.arrMu.count > 3 && self.arrMu.count <= 6){
            
            static NSString *cellName = @"HomeTwoHangTableViewCell";
            HomeTwoHangTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeTwoHangTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
            
            if (self.arrMu.count == 4) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                cell.picImage5.hidden = YES;
                cell.picImage6.hidden = YES;
                
                
                
                
            }else if (self.arrMu.count == 5) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic5 = manage(AP_HOST, [self.arrMu[4] objectForKey:@"pic"]);
                
                [cell.picImage5 sd_setImageWithURL:[NSURL URLWithString:urlVpPic5] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage5.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage5.clipsToBounds = YES;
                cell.picImage5.userInteractionEnabled = YES;
                
                cell.picImage6.hidden = YES;
                
            }else {
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic5 = manage(AP_HOST, [self.arrMu[4] objectForKey:@"pic"]);
                
                [cell.picImage5 sd_setImageWithURL:[NSURL URLWithString:urlVpPic5] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage5.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage5.clipsToBounds = YES;
                cell.picImage5.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic6 = manage(AP_HOST, [self.arrMu[5] objectForKey:@"pic"]);
                
                [cell.picImage6 sd_setImageWithURL:[NSURL URLWithString:urlVpPic6] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage6.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage6.clipsToBounds = YES;
                cell.picImage6.userInteractionEnabled = YES;
                
            }
            
            
            return cell;
            
        }else if (self.arrMu.count > 6 && self.arrMu.count <= 9){
            static NSString *cellName = @"HomeThreeHangTableViewCell";
            HomeThreeHangTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeThreeHangTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            
            if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"1"]) {
                cell.labelTeacher.text = @"普通";
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"2"]){
                cell.labelTeacher.text = @"老师";
                
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"3"]){
                cell.labelTeacher.text = @"大V";
                
            }else {
                
                cell.labelTeacher.text = @"官方";
            }
            
            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
            
            if (self.arrMu.count == 7) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic5 = manage(AP_HOST, [self.arrMu[4] objectForKey:@"pic"]);
                
                [cell.picImage5 sd_setImageWithURL:[NSURL URLWithString:urlVpPic5] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage5.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage5.clipsToBounds = YES;
                cell.picImage5.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic6 = manage(AP_HOST, [self.arrMu[5] objectForKey:@"pic"]);
                
                [cell.picImage6 sd_setImageWithURL:[NSURL URLWithString:urlVpPic6] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage6.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage6.clipsToBounds = YES;
                cell.picImage6.userInteractionEnabled = YES;
                
                NSString *urlVpPic7 = manage(AP_HOST, [self.arrMu[6] objectForKey:@"pic"]);
                
                [cell.picImage7 sd_setImageWithURL:[NSURL URLWithString:urlVpPic7] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage7.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage7.clipsToBounds = YES;
                cell.picImage7.userInteractionEnabled = YES;
                cell.picImage8.hidden = YES;
                cell.picImage9.hidden = YES;
                
                
                
                
            }else if (self.arrMu.count == 8) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic5 = manage(AP_HOST, [self.arrMu[4] objectForKey:@"pic"]);
                
                [cell.picImage5 sd_setImageWithURL:[NSURL URLWithString:urlVpPic5] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage5.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage5.clipsToBounds = YES;
                cell.picImage5.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic6 = manage(AP_HOST, [self.arrMu[5] objectForKey:@"pic"]);
                
                [cell.picImage6 sd_setImageWithURL:[NSURL URLWithString:urlVpPic6] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage6.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage6.clipsToBounds = YES;
                cell.picImage6.userInteractionEnabled = YES;
                
                NSString *urlVpPic7 = manage(AP_HOST, [self.arrMu[6] objectForKey:@"pic"]);
                
                [cell.picImage7 sd_setImageWithURL:[NSURL URLWithString:urlVpPic7] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage7.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage7.clipsToBounds = YES;
                cell.picImage7.userInteractionEnabled = YES;
                
                NSString *urlVpPic8 = manage(AP_HOST, [self.arrMu[7] objectForKey:@"pic"]);
                
                [cell.picImage8 sd_setImageWithURL:[NSURL URLWithString:urlVpPic8] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage8.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage8.clipsToBounds = YES;
                cell.picImage8.userInteractionEnabled = YES;
                
                cell.picImage9.hidden = YES;
                
                
                
            }else {
                NSString *urlVpPic1 = manage(AP_HOST, [self.arrMu[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic2 = manage(AP_HOST, [self.arrMu[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [self.arrMu[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                NSString *urlVpPic4 = manage(AP_HOST, [self.arrMu[3] objectForKey:@"pic"]);
                
                [cell.picImage4 sd_setImageWithURL:[NSURL URLWithString:urlVpPic4] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage4.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage4.clipsToBounds = YES;
                cell.picImage4.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic5 = manage(AP_HOST, [self.arrMu[4] objectForKey:@"pic"]);
                
                [cell.picImage5 sd_setImageWithURL:[NSURL URLWithString:urlVpPic5] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage5.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage5.clipsToBounds = YES;
                cell.picImage5.userInteractionEnabled = YES;
                
                
                NSString *urlVpPic6 = manage(AP_HOST, [self.arrMu[5] objectForKey:@"pic"]);
                
                [cell.picImage6 sd_setImageWithURL:[NSURL URLWithString:urlVpPic6] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage6.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage6.clipsToBounds = YES;
                cell.picImage6.userInteractionEnabled = YES;
                
                NSString *urlVpPic7 = manage(AP_HOST, [self.arrMu[6] objectForKey:@"pic"]);
                
                [cell.picImage7 sd_setImageWithURL:[NSURL URLWithString:urlVpPic7] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage7.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage7.clipsToBounds = YES;
                cell.picImage7.userInteractionEnabled = YES;
                
                NSString *urlVpPic8 = manage(AP_HOST, [self.arrMu[7] objectForKey:@"pic"]);
                
                [cell.picImage8 sd_setImageWithURL:[NSURL URLWithString:urlVpPic8] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage8.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage8.clipsToBounds = YES;
                cell.picImage8.userInteractionEnabled = YES;
                
                NSString *urlVpPic9 = manage(AP_HOST, [self.arrMu[8] objectForKey:@"pic"]);
                
                [cell.picImage9 sd_setImageWithURL:[NSURL URLWithString:urlVpPic9] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage9.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage9.clipsToBounds = YES;
                cell.picImage9.userInteractionEnabled = YES;
                
                
                
            }
            
            
            return cell;
            
        }else if ([dictOfForward length] != 0 && self.arrMu.count == 0){
            
            static NSString *cellName = @"HomeForwardOneHangCell";
            HomeForwardOneHangCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeForwardOneHangCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            
            if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"1"]) {
                cell.labelTeacher.text = @"普通";
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"2"]){
                cell.labelTeacher.text = @"老师";
                
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"3"]){
                cell.labelTeacher.text = @"大V";
                
            }else {
                
                cell.labelTeacher.text = @"官方";
            }
            
            
            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];
            
            NSMutableDictionary *dictOfward = [dict1 objectForKey:@"forward_circle"];
            cell.titleLabel.text = [dictOfward objectForKey:@"content"];
            cell.nameLabel.text =[dictOfward objectForKey:@"forward_username"];
            NSMutableArray *arrOfPic = [NSMutableArray array];
            arrOfPic = [dictOfward objectForKey:@"forward_pic"];
            
            if (arrOfPic.count == 1) {
                
                NSString *urlVpPic1 = manage(AP_HOST, [arrOfPic[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                
                cell.picImage2.hidden = YES;
                cell.picImage3.hidden = YES;
                
                
            }else if (arrOfPic.count ==2){
                NSString *urlVpPic1 = manage(AP_HOST, [arrOfPic[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                NSString *urlVpPic2 = manage(AP_HOST, [arrOfPic[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                cell.picImage3.hidden = YES;
                
            }else if (arrOfPic.count ==0){
                
                cell.picImage2.hidden = YES;
                cell.picImage3.hidden = YES;
                cell.picImage1.hidden = YES;
                
                
                
            }else {
                
                NSString *urlVpPic1 = manage(AP_HOST, [arrOfPic[0] objectForKey:@"pic"]);
                
                [cell.picImage1 sd_setImageWithURL:[NSURL URLWithString:urlVpPic1] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage1.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage1.clipsToBounds = YES;
                cell.picImage1.userInteractionEnabled = YES;
                
                NSString *urlVpPic2 = manage(AP_HOST, [arrOfPic[1] objectForKey:@"pic"]);
                
                [cell.picImage2 sd_setImageWithURL:[NSURL URLWithString:urlVpPic2] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage2.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage2.clipsToBounds = YES;
                cell.picImage2.userInteractionEnabled = YES;
                
                NSString *urlVpPic3 = manage(AP_HOST, [arrOfPic[2] objectForKey:@"pic"]);
                
                [cell.picImage3 sd_setImageWithURL:[NSURL URLWithString:urlVpPic3] placeholderImage:[UIImage imageNamed:@""]];
                
                cell.picImage3.contentMode = UIViewContentModeScaleAspectFill;
                cell.picImage3.clipsToBounds = YES;
                cell.picImage3.userInteractionEnabled = YES;
                
                
            }
            

            return cell;
            
        }else {
            
            static NSString *cellName = @"HomeNoPicTableViewCell";
            HomeNoPicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (!cell) {
                cell = [[HomeNoPicTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
                cell.delegate = self;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            [cell setCellContent:[self.dataSource objectAtIndex:indexPath.row] andIsShow:[[self.cellIsShowAll objectForKey:[NSString stringWithFormat:@"%ld", (long)indexPath.row]] boolValue]  andCellIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell callBackHymn:^{
                [self editHymnWithNSString:[dict1 objectForKey:@"id"]];
                
            }];
            
            if ([[dict1 objectForKey:@"is_up"]isEqualToString:@"1"]) {
                
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_solid"];
                
                
            }else {
                //thumb-up_solid
                
                cell.imageHymn.image = [UIImage imageNamed:@"thumb-up_icon"];;
                
            }

            cell.infolable.text =[dict1 objectForKey:@"user_name"];
            if ([[dict1 objectForKey:@"every_num"] isEqualToString:@"0"]) {
                
                cell.blueView.hidden = YES;
                
            }else {
                cell.blueView.hidden = NO;
                NSString *str = @"+";
                cell.labelWater.text =[[str stringByAppendingString:[dict1 objectForKey:@"every_num"]] stringByAppendingString:@"水滴"];
                
                
            }
            
            if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"1"]) {
                cell.labelTeacher.text = @"普通";
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"2"]){
                cell.labelTeacher.text = @"老师";
                
            }else if ([[dict1 objectForKey:@"member_type"] isEqualToString:@"3"]){
                cell.labelTeacher.text = @"大V";
                
            }else {
                
                cell.labelTeacher.text = @"官方";
            }

            cell.labelOfTime.text = [dict1 objectForKey:@"add_time"];
            cell.labelHymnNum.text = [dict1 objectForKey:@"up"];
            cell.labelComment.text = [dict1 objectForKey:@"comment"];
            //            NSString *strRead = @"阅读";
            NSString *str = [dict1 objectForKey:@"reading"];
            cell.labelRead.text = [str stringByAppendingString:@"阅读"];
            
            NSString *urlHeaderPic = manage(AP_HOST, [dict1 objectForKey:@"header_img"]);
            [cell.headImage sd_setImageWithURL:[NSURL URLWithString:urlHeaderPic] placeholderImage:[UIImage imageNamed:@""]];

            return cell;
            
        }
        
    }
    
    
}

#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 0) {
        
    }else {
        NSMutableDictionary *dict1 = self.dataArr[indexPath.row];
        HomePicDetailsViewController *vc = [[HomePicDetailsViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        vc.tieID =[dict1 objectForKey:@"id"];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    
    
    

    
}
#pragma mark -- Dalegate
- (void)remarksCellShowContrntWithDic:(NSDictionary *)dic andCellIndexPath:(NSIndexPath *)indexPath
{
    [self.cellIsShowAll setObject:[dic objectForKey:@"isShow"] forKey:[NSString stringWithFormat:@"%@",[dic objectForKey:@"row"]]];
    _isShow = [[NSString stringWithFormat:@"%@",[dic objectForKey:@"isShow"]] boolValue];
    [_tableView reloadData];
}
#pragma mark -- 点赞
- (void)editHymnWithNSString:(NSString *)circle_id{
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:circle_id forKey:@"id"];
    
    [[MNetworkHandler sharedInstance]conURL:home_CircleIndexGiveup networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            

            
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        
    }];
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
